home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
User's Choice Windows CD
/
User's Choice Windows CD (CMS Software)(1993).iso
/
win_q_t
/
trem.zip
/
DIALOG.C
< prev
next >
Wrap
Text File
|
1991-05-11
|
9KB
|
288 lines
/************************************************************************
*
* Copyright (c) 1991 Microsoft Corporation. All Rights Reserved.
*
*-----------------------------------------------------------------------
*
* Project: Windows Terminal Example
*
* Module: dialog.c
*
* Author: Bryan A. Woodruff (baw)
*
*
* Remarks: Dialog boxes are controlled with these procs.
*
* Revisions:
* 01.00.000 5/10/91 baw Wrote it.
*
************************************************************************/
#include "terminal.h"
/************************************************************************
* VOID GoModalDialogBoxParam ( HANDLE hInstance, LPSTR lpszTemplate,
* HWND hWnd, FARPROC lpDlgProc,
* DWORD dwParam )
*
* Description:
* Invokes a modal dialog box with DWORD parameter.
*
* Comments:
* 5/10/91 baw Wrote it.
*
************************************************************************/
VOID GoModalDialogBoxParam( HANDLE hInstance, LPSTR lpszTemplate,
HWND hWnd, FARPROC lpDlgProc, DWORD dwParam )
{
FARPROC lpProcInstance ;
lpProcInstance = MakeProcInstance( lpDlgProc, hInstance ) ;
DialogBoxParam( hInstance, lpszTemplate, hWnd, lpProcInstance, dwParam ) ;
FreeProcInstance( lpProcInstance ) ;
} /* end of GoModalDialogBox() */
/************************************************************************
* int GetRadioButton( HWND hDlg, int nIDFirst, int nIDLast )
*
* Description:
* Returns the ID value of the selected radio button.
*
* Comments:
* 5/11/91 baw Wrote it.
*
************************************************************************/
int GetRadioButton( HWND hDlg, int nIDFirst, int nIDLast )
{
int i ;
for (i = nIDFirst; i <= nIDLast; i++)
if (IsDlgButtonChecked( hDlg, i ))
return ( i ) ;
return ( nIDFirst ) ;
} /* end of GetRadioButton() */
/************************************************************************
* BOOL FAR PASCAL AboutDlgProc( HWND hDlg, WORD wMsg,
* WORD wParam, LONG lParam )
*
* Description:
* Puts up the ego boosting about box. :)
*
* Comments:
* 5/10/91 baw Needed an ego boost... So I wrote this
* about box.
*
************************************************************************/
BOOL FAR PASCAL AboutDlgProc( HWND hDlg, WORD wMsg, WORD wParam, LONG lParam )
{
switch (wMsg)
{
case WM_INITDIALOG:
{
char szBuffer[ 25 ] ;
wsprintf( szBuffer, "Version: %s", (LPSTR) szVersion ) ;
SetDlgItemText( hDlg, IDD_VERSION, (LPSTR) szBuffer ) ;
}
return ( TRUE ) ;
case WM_COMMAND:
if (wParam == IDD_OK)
{
EndDialog( hDlg, TRUE ) ;
return ( TRUE ) ;
}
break;
}
return ( FALSE ) ;
} /* end of AboutDlgProc() */
/************************************************************************
* BOOL SettingsDlgInit( HWND hDlg, LOCALHANDLE hTermInfo )
*
* Description:
* Puts current settings into dialog box (via CheckRadioButton() etc.)
*
* Comments:
* 5/11/91 baw Wrote it.
*
************************************************************************/
BOOL SettingsDlgInit( HWND hDlg, LOCALHANDLE hTermInfo )
{
int i ;
NPTERMINFO npTermInfo ;
if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
return ( FALSE ) ;
CheckRadioButton( hDlg, IDD_COM1, IDD_COM4,
npTermInfo -> bPort + IDD_COM1 - 1 ) ;
// disable COM port options if connected
for (i = IDD_COM1; i <= IDD_COM4; i++)
EnableWindow( GetDlgItem( hDlg, i ), !(npTermInfo -> fConnected) ) ;
for (i = 0; i < MAXBAUDRATES; i++)
if (npTermInfo -> wBaudRate == awBaudRates[i])
break;
CheckRadioButton( hDlg, IDD_1200, IDD_9600, IDD_1200 + i ) ;
CheckRadioButton( hDlg, IDD_DATABITS5, IDD_DATABITS8,
IDD_DATABITS5 + npTermInfo -> bByteSize - 5 ) ;
CheckRadioButton( hDlg, IDD_NONE, IDD_SPACE,
IDD_NONE + npTermInfo -> bParity - NOPARITY ) ;
CheckRadioButton( hDlg, IDD_STOPBITS1, IDD_STOPBITS2,
IDD_STOPBITS1 + npTermInfo -> bStopBits - ONESTOPBIT ) ;
CheckDlgButton( hDlg, IDD_HARDWARE,
(npTermInfo -> bFlowCtrl & FC_HARDWARE) > 0 ) ;
CheckDlgButton( hDlg, IDD_SOFTWARE,
(npTermInfo -> bFlowCtrl & FC_SOFTWARE) > 0 ) ;
CheckDlgButton( hDlg, IDD_AUTOWRAP, npTermInfo -> fAutoWrap ) ;
CheckDlgButton( hDlg, IDD_NEWLINE, npTermInfo -> fNewLine ) ;
CheckDlgButton( hDlg, IDD_LOCALECHO, npTermInfo -> fLocalEcho ) ;
LocalUnlock( hTermInfo ) ;
return ( TRUE ) ;
} /* end of SettingsDlgInit() */
/************************************************************************
* BOOL SettingsDlgTerm( HWND hDlg, LOCALHANDLE hTermInfo )
*
* Description:
* Puts dialog contents into current settings.
*
* Comments:
* 5/11/91 baw Wrote it.
*
************************************************************************/
BOOL SettingsDlgTerm( HWND hDlg, LOCALHANDLE hTermInfo )
{
NPTERMINFO npTermInfo ;
if (NULL == (npTermInfo = (NPTERMINFO) LocalLock( hTermInfo )))
return ( FALSE ) ;
if (!npTermInfo -> fConnected)
npTermInfo -> bPort =
(BYTE)(GetRadioButton( hDlg, IDD_COM1, IDD_COM4 ) - IDD_COM1 + 1) ;
npTermInfo -> wBaudRate =
awBaudRates[GetRadioButton( hDlg, IDD_1200, IDD_9600 ) - IDD_1200] ;
npTermInfo -> bByteSize =
(BYTE)(GetRadioButton( hDlg, IDD_DATABITS5, IDD_DATABITS8 ) - IDD_DATABITS5 + 5 ) ;
npTermInfo -> bParity =
(BYTE)(GetRadioButton( hDlg, IDD_NONE, IDD_SPACE ) - IDD_NONE + NOPARITY) ;
npTermInfo -> bStopBits =
(BYTE)(GetRadioButton( hDlg, IDD_STOPBITS1, IDD_STOPBITS2 ) - IDD_STOPBITS1 + ONESTOPBIT) ;
if (IsDlgButtonChecked( hDlg, IDD_HARDWARE))
npTermInfo -> bFlowCtrl |= FC_HARDWARE ;
else
npTermInfo -> bFlowCtrl &= ~FC_HARDWARE ;
if (IsDlgButtonChecked( hDlg, IDD_SOFTWARE))
npTermInfo -> bFlowCtrl |= FC_SOFTWARE ;
else
npTermInfo -> bFlowCtrl &= ~FC_SOFTWARE ;
npTermInfo -> fAutoWrap = IsDlgButtonChecked( hDlg, IDD_AUTOWRAP ) ;
npTermInfo -> fNewLine = IsDlgButtonChecked( hDlg, IDD_NEWLINE ) ;
npTermInfo -> fLocalEcho = IsDlgButtonChecked( hDlg, IDD_LOCALECHO ) ;
LocalUnlock( hTermInfo ) ;
return ( TRUE ) ;
} /* end of SettingsDlgTerm() */
/************************************************************************
* BOOL FAR PASCAL SettingsDlgProc( HWND hDlg, WORD wMsg,
* WORD wParam, LONG lParam )
*
* Description:
* This handles all of the settings for Terminal.
*
* Comments:
* 5/10/91 baw Wrote it.
*
************************************************************************/
BOOL FAR PASCAL SettingsDlgProc( HWND hDlg, WORD wMsg,
WORD wParam, LONG lParam )
{
static LOCALHANDLE hTermInfo ;
switch (wMsg)
{
case WM_INITDIALOG:
hTermInfo = LOWORD( lParam ) ;
return ( SettingsDlgInit( hDlg, hTermInfo ) ) ;
case WM_COMMAND:
switch (wParam)
{
case IDD_COM1:
case IDD_COM2:
case IDD_COM3:
case IDD_COM4:
CheckRadioButton( hDlg, IDD_COM1, IDD_COM4, wParam ) ;
return ( TRUE ) ;
case IDD_1200:
case IDD_2400:
case IDD_4800:
case IDD_9600:
CheckRadioButton( hDlg, IDD_1200, IDD_9600, wParam ) ;
return ( TRUE ) ;
case IDD_DATABITS5:
case IDD_DATABITS6:
case IDD_DATABITS7:
case IDD_DATABITS8:
CheckRadioButton( hDlg, IDD_DATABITS5, IDD_DATABITS8, wParam ) ;
return ( TRUE ) ;
case IDD_NONE:
case IDD_EVEN:
case IDD_ODD:
case IDD_MARK:
case IDD_SPACE:
CheckRadioButton( hDlg, IDD_NONE, IDD_SPACE, wParam ) ;
return ( TRUE ) ;
case IDD_STOPBITS1:
case IDD_STOPBITS15:
case IDD_STOPBITS2:
CheckRadioButton( hDlg, IDD_STOPBITS1, IDD_STOPBITS2, wParam ) ;
return ( TRUE ) ;
case IDD_OK:
// Copy stuff into structure
SettingsDlgTerm( hDlg, hTermInfo ) ;
EndDialog( hDlg, TRUE ) ;
return ( TRUE ) ;
case IDD_CANCEL:
// Just end
EndDialog( hDlg, TRUE ) ;
return ( TRUE ) ;
}
break;
}
return ( FALSE ) ;
} /* end of SettingsDlgProc() */
/************************************************************************
* End of File: dialog.c
************************************************************************/